<template>
	 <view style="width: 100vw;height: 100vh;background-color: #f0f0f0;">
		 <!-- <pdascan></pdascan> -->
		 {{title}}
		 
		<view v-if="templetName == 'appsj_index' || templetName == 'appsj_index_pda'" style="margin-bottom: 48px;">
		 	<cover-view v-if="JSON.stringify(topshops)!='[]'" style="background-color: #007AFF;display: flex;flex-direction: row;padding-bottom: 10px;position: fixed;z-index: 999999999; top: 0;height: 30px;width: 100vw;">
				<cover-view @click="openmask" style="padding-left: 5px; font-size: 14px; display: flex;justify-content: center; flex-direction: row;align-items: center;color: #fff; ">
				<cover-view style="display: flex;">{{topshops.value[shopindex].mc}}</cover-view>
				 <cover-image style="margin-left: 5px;width: 18px;height: 18px;" src="../../static/images/indexdown.png"></cover-image> 
				</cover-view>
				<cover-view @click="btnclick('input','')" style="background-color: rgba(0,191,255,0.2); vertical-align: middle;padding:0 5px;margin: 0px 5px; border-radius: 15px;display: flex;align-items: center;flex: 1; ">
					<cover-image src="../../static/images/indexsearch.png" style="padding-right: 5px;display: flex;width: 18px;height: 18px;"></cover-image>
				 </cover-view>
				 <cover-image @click="btnclick('scan','')" style="padding: 5px; margin-right: 5px; font-size: 18px;display: flex;align-items: center;width: 20px;height: 20px;" src="../../static/images/indexscan.png"></cover-image>
			</cover-view> 
			
			
			<swiper v-if="JSON.stringify(topsumnumbers)!='[]'" class="swiper" indicator-dots="true"  :style="{marginTop:JSON.stringify(topshops)!='[]'?'30px':0}"  style="width: 100vw;height: 130px;padding-top: 10px; background-color: #007AFF;">
				<swiper-item v-for="(swipeitem, index) in topsumnumbers.value" :key="index">
					<view style="width: 100vw;height: 110px;background-color: #007AFF;">
						<view style="display: flex;flex-direction: column;align-items: center; color: #fff;position: relative;">
							<view style="font-size: 18px;font-weight: 700;display: flex;">{{swipeitem.title}}</view>
						</view>
						<view style="margin: 20px 10px 20px 10px;display: flex;color: #fff;">
							<view style="width: 50%;display: flex;align-items: center;flex-direction: column;padding: 10px 0;">
								<view style="font-size: 20px;font-weight: 700;"><text>{{swipeitem.leftstring}}</text></view>
							</view>
							<view style="width: 1px;background-color: #f0f0f0;margin: 10px 0;"></view>
							<view style="width: 50%;display: flex;align-items: center;flex-direction: column;padding: 10px 0;">
								<view style="font-size: 20px;font-weight: 700;"><text>{{swipeitem.rightstring}}</text></view>
							</view>
						</view>
					</view>
				</swiper-item>
			</swiper>
			
			<view v-if="JSON.stringify(toptasks)!='[]'" style="width: 100vw;height: 110px; background-image: url(http://www.hbxtwl.com/images/whitebrige.png);background-size:100% 100%; background-color: #007AFF;">
				<view style="width: 100vw;height: 30px;"></view>
				<view style="display: flex;align-items: center;width: 100%;flex-wrap: wrap;">
					<view @click="navigateto(item)" v-for="(item,index) in toptasks.value" :key="index" style="display: flex;justify-content: center;font-size: 12px;color: #333; align-items: center;flex-direction: column;width: 25%;padding: 5px 0;">
						<view style="position: relative;"> 
							<image style="width: 44px;height: 44px;" :src="item.pic"></image>
							<view v-if="item.count>0" style="position: absolute;top: 0; right:-5px;color: #fff;; background-color: #e85a71;border-radius: 16px;padding: 0 5px;font-size: 12px;">{{item.count}}</view>
						</view>
						<view>{{item.title}}</view>
					</view>
				</view>
			</view>
			
			 <view style="display: flex;flex-direction: row;" v-if="JSON.stringify(dhtzarr) != '[]'">
				<swiper  class="swiper_container" vertical="true" autoplay="true" circular="true" interval="3000">
				 <block v-for="(item,index) in dhtzarr" :key="index" >
				 <navigator :url="'/pages/zxggdetail/zxggdetail?item='+JSON.stringify(item)" open-type="navigate">
				  <swiper-item>
				  <view class="swiper_item"> <view class="swiper_txt"><text class="iconfont icon-xiaoxi"></text> {{item.title}}</view> </view>
				  </swiper-item>
				 </navigator>
				 </block>
				</swiper>
			<view @click="navitozz" style="display: flex;line-height: 50rpx;color: #999999;padding-bottom: 2px;align-items: center;text-align: center;" class="iconfont icon-jiantou"> </view>
			</view> 
			
			<view :style="{'background-color':templetName=='appsj_index'?'#fff':'#f0f0f0;'}">
				<view style="display: flex;align-items: center;justify-content: space-between;padding: 10px;">
					<view >{{commandtitle}}</view>
					<view @click="navitocustom" class="iconfont icon-bianji" style="padding: 2px 5px;"></view>
				</view>
				<view v-if="templetName == 'appsj_index'" class="cmd">
					<view @click="navigatetocom(item)" v-for="(item,index) in commonmod.value" :key="index" class="cmdi" style="width: 25%;">
						<image style="width: 44px;height: 44px;" :src="item.piciconurl"></image>{{item.menuname}}
					</view>
				</view>
				<view v-else-if="templetName  == 'appsj_index_pda'" class="cmd">
					<view @click="navigatetocom(item)" v-for="(item,index) in commonmod.value" :key="index"  class="cmdi" style="width: 33%;font-size: 20px;">
						<image style="width: 55px;height: 55px;" :src="item.piciconurl"></image>{{item.menuname}}
					</view>
				</view>
			</view>
			 
			<view v-for="(item,index) in chartList" :key="index">
				 <view v-if="item.divType==='rating'">
					 <orders :charttype="item.divType" :injson="item.injson" :style="item.style"  ref="orders"></orders>
					 <view class="split"></view>
				 </view>
				 <view v-else>
					<ring :charttype="item.divType" ref="rings"></ring>
					<view class="split"></view>
				 </view>
			</view>
			<cover-view v-if="ismask" @click="closemask" style="backface-visibility: hidden;top: 0;right: 0;left: 0;bottom: 0;position: fixed;overflow: hidden;width: 100%;height: 100%;opacity: 1;background-color: rgba(0,0,0,0.4);z-index: 999999999;">
				<cover-view @click.stop="" :style="{'margin-top':layerheightmargin+'px','height':layerheight+'px'}" style="border-radius: 10px; margin-left: 80px; opacity: 1;width: calc(100vw - 160px);background-color: #fff;z-index: 999999999;">
					<cover-view style="margin: 5px 0 ;overflow-y: scroll;overflow-x: hidden;height: 100%;position: relative;">
						<cover-view  style="display: flex;flex-direction: column;padding: 0 20px;">
							<cover-view style="display: flex;flex-direction: row;align-items: center;padding: 10px 0;">
								<cover-view style="height: 10px;width: 3px;background-color: #F55C23;display: flex;margin-left: -20px;margin-right: 17px;"></cover-view> 选择门店
							</cover-view>
							<cover-view @click.stop="selectlayer(index2)" v-for="(item2, index2) in topshops.value" :key="index2" >
								<cover-view style=" height: 1px;width: 100%;border-bottom: #f0f0f0 1px dashed;"></cover-view>
								<cover-view  style="padding: 10px 0; color: #666;font-size: 14px; display: flex;flex-direction: row;justify-content: space-between;">
									<cover-view>{{item2.mc}}</cover-view>
									<cover-image v-if="shopindex==index2" style="width: 18px;height: 18px;color: #F55C23;" class="iconfont icon-dui"></cover-image>
								</cover-view>
							</cover-view> 
						</cover-view>
					</cover-view>
				</cover-view>
			</cover-view>
		</view>
		<tabbar :value2='0' ></tabbar>
		
	</view>
 </template>


<script>
	var util = require("../../utils/util.js");
	import tabbar from "@/components/tabbar/tabbar.vue"
	// import pdascan from "@/components/pda-scan/pda-scan.vue"
	export default {
		components:{
			tabbar:tabbar
			// pdascan:pdascan
		},
		data() {
			return {
				code : '01',
				searchbar:{},
				topsumnumbers:[],
				topshops:[],
				toptasks:[],
				commonmod:[],
				ismask:false,
				shopindex:0,
				layerheight:0,
				chartList:[],
				dhtzarr:[],
				div:[],
				errmsg:'',
				pageName:'',
				templetName:'',
				modid:'',
				menuid:'',
				btns:[],
				layerheightmargin:0,
				clientHeight:0,
				layercontent:{},
				conditions:{},
				conditionsname:'',
				isIphoneXOrAbove:false,
				preoptions:{},
				pageConditions:{"pageNumber": 1,"rowsPerPage": 20,"isAllData": false},
				inputVal:'',
				isfocus:false,
				ispo:false,
				page:{},
				clientType:'',
				times:'',
				interval:'',
				title:'',
				commandtitle:'常用功能',
				main:'',
				receiver:''
			}
		},
		
		//del /s /a .DS_Store在Windows上处理或删除这些.DS_Store文件

		onLoad: function(options) {
			var that = this
			uni.hideTabBar()
			
			
			
			uni.getSystemInfo({
			  success: function(res) {
				  // if ((res.model.includes("iPhone 11") || res.model.includes("iPhone 12") || res.model.includes("iPhone 13") || res.model.includes("iPhone15") || res.model.includes("iPhone16") || res.model.includes("iPhone14")) || (res.model.includes("iPhone") && (res.model.includes("Pro") || res.model.includes("mini") || res.model.includes("X"))) && (res.statusBarHeight > 20)) {
			    if ((res.statusBarHeight > 30 && !res.model.includes('TN28') &&  !res.model.includes('TC21'))) {
				  uni.setStorageSync('bottommargin',true)
			    }else{
					uni.setStorageSync('bottommargin',false)
				}
			  }
			});
			
			this.clientType = uni.getStorageSync('clientType')
			if(this.clientType == 'pda') getApp().globalData.fontsize='20px'
			console.log(this.clientType)
			that.$options.methods.initial(true,that)
			let  i18n = uni.getStorageSync('i18n')
			if(i18n === 'en'){
				uni.setNavigationBarTitle({'title':'Home'})
				this.commandtitle = 'Common functions'
			}
			
			
			
		},

		onShow:function(options){
			let that = this
			uni.hideTabBar()
			//6932691916572
			
		// uni.$on('scancodedate',function(data){  
		//             console.log('你想要的code：', data.code)  
		//         }) 
			const systemInfo = uni.getSystemInfoSync();
			
			let deviceModel = systemInfo.model;
			if(deviceModel === '95W Series'){
				uni.setStorageSync('pdaAction','android.intent.action.SCANRESULT')
				uni.setStorageSync('pdaExtra','value')
			}else if(deviceModel === 'C68' || deviceModel === 'PDA'){ 
				uni.setStorageSync('pdaAction','com.android.decodewedge.decode_action')
				uni.setStorageSync('pdaExtra','com.android.decode.intentwedge.barcode_string')
			}else if(deviceModel === 'TN28' || deviceModel==='TC21'){ //TC21
				uni.setStorageSync('pdaAction','com.dwbasicintent1.ACTION')
				uni.setStorageSync('pdaExtra','com.symbol.datawedge.data_string')
			}else{
				uni.setStorageSync('pdaAction','com.android.decodewedge.decode_action')
				uni.setStorageSync('pdaExtra','com.android.decode.intentwedge.barcode_string')
			} 
			console.log('设备型号:', deviceModel);
			
			
			// #ifdef APP-PLUS
			let main = plus.android.runtimeMainActivity(); //获取activity
			this.main = main
			let context = plus.android.importClass('android.content.Context'); //上下文    
			let receiver = plus.android.implements('io.dcloud.feature.internal.reflect.BroadcastReceiver', {  
				onReceive: doReceive  
			});  
			this.receiver = receiver
			let IntentFilter = plus.android.importClass('android.content.IntentFilter');  
			let Intent = plus.android.importClass('android.content.Intent');  
			let filter = new IntentFilter(); 
			//针对优博讯安卓PDA-i6300A添加监听，其它优博讯的型号应该一样或类似  
			//驰腾 com.android.decodewedge.decode_action
			//idata 95w android.intent.action.SCANRESULT
			// filter.addAction("com.android.decodewedge.decode_action"); //监听扫描  
			filter.addAction(uni.getStorageSync('pdaAction')); //监听扫描  
			main.registerReceiver(receiver, filter); //注册监听    

			function doReceive(context, intent) {  
				//通过intent实例引入intent类，方便以后的‘.’操作    
				plus.android.importClass(intent);  
				console.log('pdaextra')
				//条码内容  
				// 驰腾 com.android.decode.intentwedge.barcode_string
				// idata95w value
				// let barcode = intent.getStringExtra("com.android.decode.intentwedge.barcode_string"); // 广播标签
				let barcode = intent.getStringExtra(uni.getStorageSync('pdaExtra')); // 广播标签
				console.log("进入了onReceive",barcode);
			  
				//条码类型  
				// let barcodeType = intent.getStringExtra("com.android.decode.intentwedge.barcode_type");  

				// uni.showModal({  
				//  content: '条码:' + barcode + '\r\n长度:' + barcode.length + '\r\n类型:' + barcodeType,  
				//  showCancel: false  
				// });  
				that.inputblur(barcode)  
				//main.unregisterReceiver(receiver);//取消监听    
			}  


			function byteToString(arr) {  
				if (typeof arr === 'string') {  
					return arr;  
				}  
				var str = '',  
					_arr = arr;  
				for (var i = 0; i < _arr.length; i++) {  
					var one = _arr[i].toString(2),  
						v = one.match(/^1+?(?=0)/);  
					if (v && one.length == 8) {  
						var bytesLength = v[0].length;  
						var store = _arr[i].toString(2).slice(7 - bytesLength);  
						for (var st = 1; st < bytesLength; st++) {  
							store += _arr[st + i].toString(2).slice(2);  
						}  
						str += String.fromCharCode(parseInt(store, 2));  
						i += bytesLength - 1;  
					} else {  
						str += String.fromCharCode(_arr[i]);  
					}  
				}  
				return str;  
			}  
			
			// #endif
			
			
			// #ifdef APP-PLUS
			// this.stop()
			// #endif
			
		},
		
		onHide:function(){
			console.log('indexonhide')
			// #ifdef APP-PLUS
				if(this.main != ''){
					this.main.unregisterReceiver(this.receiver);//取消监听
					this.main =  ''
					this.receiver = ''
				}
			// #endif
		},
		
		onUnload:function(){
			console.log('indexonUnload')
			// #ifdef APP-PLUS
				if(this.main != ''){
					this.main.unregisterReceiver(this.receiver);//取消监听
					this.main =  ''
					this.receiver = ''
				}
			// #endif
		},
		
		
		components: {},
		
		onPullDownRefresh:function(){
			var that = this
			that.$options.methods.initial(false,that)
		},
		
		
		methods:{
		
			stop(){
			    var interval = setInterval(function(){
			        uni.hideKeyboard();
			    },20);
				var times = setTimeout(() => {
				    clearInterval(interval);
				},3000000);
				// var interval = setTimeout(function(){
				//     uni.hideKeyboard();
				// },20);
				// var times = setTimeout(() => {
				//     clearTimeout(interval);
				// },3000000);
				uni.switchTab({
					url:'../index/index'
				})
				this.times = times
				this.interval = interval
				this.isfocus = false
				this.$nextTick(() => {
					this.isfocus = true
					uni.hideKeyboard();
				});
			},
			
			inputblur(res){
				var that = this
				// this.inputVal = 'aa'
				// this.$nextTick(() => {
				// 	this.inputVal = ''
				// });
				// var scanValue = res.detail.value
				console.log(res)
				var scanValue = res
				if(scanValue === '' || scanValue =='aa')return
				console.log(scanValue)
				try{
					if(scanValue.indexOf('{')!=-1 && scanValue[0]!='{'){
						scanValue = scanValue.substring(scanValue.indexOf('{'))
					}
					
					var scanObj = JSON.parse(scanValue)
					if(JSON.stringify(scanObj).indexOf('{')==-1){
						throw Error('扫描数据出错')
					}
					
					var scanOpenModArr = this.page.scanOpenModArr
					console.log(JSON.parse(JSON.stringify(scanOpenModArr)))
					for(var k=0; k<scanOpenModArr.length; k++){
						var val = scanOpenModArr[k]
						var parseQR = val.parseQR
						var event = val.event 
						var expArgs = event.expArgs
						var conditions = {}
						parseQR.forEach((pval)=>{
							if(scanObj[pval.scanKey] === undefined || scanObj[pval.scanKey] === ''){
								throw Error('条码不正确!')
								return
							}
							expArgs.forEach((aval)=>{
								if(pval.colName == aval.colName){
									conditions[aval.colName] = scanObj[pval.scanKey]
								}
							})
						})
						var toDo = event.toDo
						if(toDo == 'openmod'){
							var templetname = event.templetName
							var modid = event.modId
							var pagename = event.pageName
							var menuname = event.title
							var menuid = ''
							if(templetname == 'appsj_list'){
								var url = `/pages/infolist/infolist`
										 +`?templatename=${templetname}`
										 +`&pagename=${pagename}`
										 +`&menuid=${menuid}`
										 +`&menuname=${menuname}`
										 +`&modid=${modid}`
										 +`&conditions=${JSON.stringify(conditions)}`
								uni.navigateTo({url:url})
							}
						}
					}
				}catch(e){
					console.log(e.message)
					if(e.message!=''){
						uni.showModal({
							title: '提示',
							content:e.message,
							showCancel:false,
							success: function (res) {
								if (res.confirm) {
									that.isfocus = false
									that.$nextTick(() => {
										that.isfocus = true
										uni.hideKeyboard();
									});
								}
							}
						})
					}
				}
				
			},
			
			initial(isfirst,that){
				var productCode = uni.getStorageSync('productCode')
				if (productCode === undefined || productCode === '') {
					uni.reLaunch({url: '/pages/first/first'})
					return
				}
				var sessionId = uni.getStorageSync('sessionId')
				if(sessionId === undefined || sessionId === ''){
					uni.reLaunch({url:'/pages/register/register'})
					return
				}
				var projectCode = uni.getStorageSync('projectCode')
				var terminaltype = uni.getStorageSync('terminaltype')
				var dbId = uni.getStorageSync('dbId')
				var userId = uni.getStorageSync('userId')
				var userName = uni.getStorageSync('userName')
				var pageName = uni.getStorageSync('pageName')
				var templetName = uni.getStorageSync('templetName')
				that.templetName = templetName
				
				
				if(templetName == 'appsj_list'){
					var pageName2 = uni.getStorageSync('pageName')
					var templetName2 = uni.getStorageSync('templetName',)
					var modid = uni.getStorageSync('modid')
					var menuid = uni.getStorageSync('menuid')
					uni.reLaunch({
						url:'../infolist/infolist?templatename='+templetName2+'&pagename='+pageName2+'&menuid='+menuid+'&menuname=首页&modid='+modid
					})
					return
				}
				
				if(templetName == 'appsj_index' || templetName == 'appsj_index_pda'){
					var preoptions = {}
					preoptions['pagename'] = pageName
					preoptions['templatename'] = templetName
					preoptions['modid'] = templetName
					preoptions['menuid'] = ''
					that.preoptions = preoptions
					var injson = that.$requestStylePre(preoptions)
					console.log(injson)
					uni.request({
						url: getApp().globalData.app_address + '?method=saas_PageStyle&parse=json',
						data: injson,
						method: 'POST',
						header: { 'content-type': 'application/x-www-form-urlencoded' },
						success: function(res) {
							var result = res.data;
							uni.stopPullDownRefresh()
							console.log(JSON.parse(JSON.stringify(result)))
							try{
								var title = result.data.page.title==undefined?'首页': result.data.page.title
								that.page = result.data.page
								let  i18n = uni.getStorageSync('i18n')
								if(i18n === 'en'){
									uni.setNavigationBarTitle({'title':'Home'})
								}else{
									uni.setNavigationBarTitle({title:title})
								}
							}catch(e){
								uni.reLaunch({url:'../first/first'})	
							}
							var searchbar = ''
							var topsumnumbers = ''
							var tasks = ''
							var commonmod = ''
							var chartList = []
							try{
								var div = result.data.div
								that.div = div
								let i18nArr = uni.getStorageSync('i18nArr')
								let i18n = uni.getStorageSync('i18n')
								for(var i=0; i<div.length; i++){
									
									if(div[i].divType == 'searchbar'){
										searchbar = div[i].style
										var injson = that.$requestDataPre(preoptions,div[i].divArea,searchbar.dataObject,{},{},that.pageConditions)
										uni.request({
											url: getApp().globalData.app_address + '?method=saas_PageDivData&parse=json',
											data: injson,
											method: 'POST',
											header: { 'content-type': 'application/x-www-form-urlencoded' },
											success: function(res) {
												var result = res.data;
												console.log(result)
												if(result.rtn == 1 && JSON.stringify(result.data.div.value) != '[]'){
													var values = result.data.div.value
													searchbar['value']  = values
												}
												that.topshops = searchbar
												that.$forceUpdate()
											},
										})
									}
									else if(div[i].divType == 'topsumnumbers'){
										topsumnumbers = div[i].style
										var replaceConditions = {}
										var replaceColumns = div[i].style.replaceColumns!=undefined?div[i].style.replaceColumns:[]
										replaceConditions = that.$replaceConditionstrans(replaceConditions, replaceColumns,style,'')
										var injson = that.$requestDataPre(preoptions,div[i].divArea,topsumnumbers.dataObject,replaceConditions,{},that.pageConditions)
										uni.request({
											url: getApp().globalData.app_address + '?method=saas_PageDivData&parse=json',
											data: injson,
											method: 'POST',
											header: { 'content-type': 'application/x-www-form-urlencoded' },
											success: function(res) {
												var result = res.data;
												if(result.rtn == 1 && JSON.stringify(result.data.div.value) != '[]'){
													var values = result.data.div.value
													topsumnumbers['value']  = values
													
												}
												that.topsumnumbers = topsumnumbers
												
												that.$forceUpdate()
											},
										})
									}
									else if(div[i].divType == 'tasks'){
										tasks = div[i].style
										var injson = that.$requestDataPre(preoptions,div[i].divArea,tasks.dataObject,{},{},that.pageConditions)
										uni.request({
											url: getApp().globalData.app_address + '?method=saas_PageDivData&parse=json',
											data: injson,
											method: 'POST',
											header: { 'content-type': 'application/x-www-form-urlencoded' },
											success: function(res) {
												var result = res.data;
												if(result.rtn == 1 && JSON.stringify(result.data.div.value) != '[]'){
													var values = result.data.div.value
													for(var j=0;j<values.length;j++){
														values[j].pic = getApp().globalData.pic_address + values[j].pic
													}
													tasks['value']  = values
													
												}
												that.toptasks = tasks
												that.$forceUpdate()
											},
										})
									}
									else if(div[i].divType == 'commonmod' ||div[i].divType == "commonmod_pda"){
										commonmod = div[i].style
										var replaceConditions = {}
										var replaceColumns = commonmod.replaceColumns
										if(JSON.stringify(replaceColumns) != '[]'){
											for(var m=0;m<replaceColumns.length;m++){
												replaceConditions[replaceColumns[m].toReplace] = replaceColumns[m].value
											}
										}
										var injson = that.$requestDataPre(preoptions,div[i].divArea,commonmod.dataObject,replaceConditions,{},that.pageConditions)
										console.log(injson)
										uni.request({
											url: getApp().globalData.app_address + '?method=saas_PageDivData&parse=json',
											data: injson,
											method: 'POST',
											header: { 'content-type': 'application/x-www-form-urlencoded' },
											success: function(res) {
												var result = res.data;
												console.log('commonres',result)
												if(result.rtn == 1 && JSON.stringify(result.data.div.value) != '[]'){
													var values = result.data.div.value
													for(var j=0;j<values.length;j++){
														values[j].piciconurl = getApp().globalData.pic_address + values[j].piciconurl
														if(i18n === 'en' && i18nArr!=undefined){
															values[j].menuname = that.$translg(values[j].menuname,i18nArr)
														}
													}
													var id = ''
													var pid = ''
													values = that.$structureTreeData(values, id = "menuid", pid ="parentmenuid")
													
													commonmod['value']  = values
												}
												that.commonmod = commonmod
												console.log('that.commonmod',that.commonmod)
												that.$forceUpdate()
											},
										})
									}
									else if(div[i].divType == "chart_rating"){
										var style = div[i].style
										style.name = div[i].name
										var replaceConditions = {}
										var replaceColumns = div[i].style.replaceColumns!=undefined?div[i].style.replaceColumns:[]
										replaceConditions = that.$replaceConditionstrans(replaceConditions, replaceColumns,style,'')
										var injson = that.$requestDataPre(preoptions,div[i].divArea,style.dataObject,replaceConditions,{},that.pageConditions)
										var chartitem = {}
										chartitem['divType'] = style.type
										chartitem['style'] = style
										chartitem['injson'] = injson
										chartList.push(chartitem)
									}
									else if(div[i].style.divType == 'chart_mix'){
										var style = div[i].style
										style.name = div[i].name
										chartList.push(style)
									}
									else if(div[i].style.divType == 'chart_pie'){
										var style = div[i].style
										style.name = div[i].name
										chartList.push(style)
									}
								}
								that.chartList = chartList
								that.$forceUpdate()
								console.log(isfirst)
								var loginid = uni.getStorageSync('userName')
								console.log(loginid)
								if(isfirst){
									var injson = '{"terminalType":"' + terminaltype + '","projectCode":"' + projectCode +'","dbId":"' + dbId +'","sessionId":"'+sessionId+'"}';
									uni.request({
										url: getApp().globalData.app_address + '?method=page_DataObjectExtData&parse=json',
										data: injson,
										method: 'POST',
										header: { 'content-type': 'application/x-www-form-urlencoded' },
										success: function(res) {
											var result = res.data;
											uni.setStorageSync('DataObjectExtData',result.data)
										},
									})
									
									
									var wx_appid = uni.getStorageSync('wx_appid')==undefined ? '':uni.getStorageSync('wx_appid')
									var wx_serviceid = uni.getStorageSync('wx_serviceid')==undefined?'':uni.getStorageSync('wx_serviceid')
									
									if(that.clientType != 'pda' && loginid!='软通测试'){
										uni.login({
											success:function(res){
												var code = res.code
												var projectCode = uni.getStorageSync('projectCode')
												var accountName = uni.getStorageSync('accountName')
												if(projectCode.indexOf('SRM')!=-1){
													var url = 'https://www.hbxtwl.com/mxdzapi/getopenidnbmtdhpt?code='+code
												}
												if(projectCode.indexOf('ERP')!=-1){
													var url = 'https://www.hbxtwl.com/mxdzapi/getopenidnbmtglpt?code='+code
												}
												wx.request({
												  url: url,
												  data: {},
												  method: 'GET',
												  header: {'content-type': 'application/json'},
												  success: function (res) {
													  var openid = res.data.openid==undefined?'':res.data.openid
													  var unionid = res.data.unionid==undefined?'':res.data.unionid
													uni.request({
														url: getApp().globalData.pic_address+'mxdzapi/getwxuser',
														data: {unionid:unionid},
														method: 'POST',
														header: {'content-type': 'application/x-www-form-urlencoded'},
														success: function(res) {
															console.log(res)
															var data = res.data.DATA
															if(data!=''){
																var serviceId = data.wxserviceid
																uni.setStorageSync('wx_serviceid',serviceId)
																if(serviceId === '' || serviceId!=wx_serviceid){
																	uni.showModal({
																		title: '提示',
																		content: '请您关注美星电子公众号，关注后请点击一下确认接收消息',
																		success: (res) => {
																			if(res.confirm) {  
																				uni.navigateTo({url:'../webview/webview'})
																			}  
																		} 
																	})
																}
															}
															if(wx_appid==''  || (wx_appid!=''&&wx_appid!=openid) || (serviceId!=wx_serviceid)){
																  var injsonwxid = that.$requestAppId(openid,unionid,serviceId)
																  console.log(injsonwxid)
																  uni.request({
																	url: getApp().globalData.app_address,
																	data: {method: 'saas_MsgInitWeChatAppId',parse: 'json',inJson: injsonwxid},
																	method: 'GET',
																	header: {'content-type': 'application/json'},
																	success: function(res) {
																		console.log('saas_MsgInitWeChatAppId')
																		console.log(res)
																	},
																})
															}
														},
													})
													  
													},
												})
											}
										})
										
									}
								}
							
							}catch(e){}
						},
					})
					
					
				}
			},
			
			navitocustom(){
				uni.navigateTo({
					url:'../custommenu/custommenu'
				})
			},
			
			navigatetocom(item){
				var that = this
				console.log(item)
				
				var templatename = item.templetname
				var pagename = item.pagename
				var menuid = item.menuid
				var menuname = item.menuname
				var modid = item.modid
				if(templatename == 'appsj_list'){
					uni.navigateTo({url:'/pages/infolist/infolist?templatename='+templatename+'&pagename='+pagename+'&menuid='+menuid+'&menuname='+menuname+'&modid='+modid})
				}else if(templatename == 'appsj_tab'){
					uni.navigateTo({url:'/pages/tab/tab?templatename='+templatename+'&pagename='+pagename+'&menuid='+menuid+'&menuname='+menuname+'&modid='+modid+'&tabs='+JSON.stringify(item.children)})
				}
			},
			
			navitozz(){
				uni.navigateTo({
					url:'../zxgglist/zxgglist'
				})
			},
			closemask(){
				var that = this
				that.ismask = false
				
			},
			
			selectlayer(index){
				var that= this
			},
			
			openmask(){
				var that = this
				if(JSON.stringify(that.topshops.value)!='[]'){
					that.ismask = true
					that.layercontent = that.topshops
					that.layerheight = 44  + that.topshops.length * 44
					that.layerheightmargin = (that.clientHeight - that.layerheight)/2
				}
			},
		
			reload(){
				var that = this
				var productCode = uni.getStorageSync('productCode')
				var sessionId = uni.getStorageSync('sessionId')
				var projectCode = uni.getStorageSync('projectCode')
				var terminaltype = uni.getStorageSync('terminaltype')
				var dbId = uni.getStorageSync('dbId')
				var userId = uni.getStorageSync('userId')
				var userName = uni.getStorageSync('userName')
				var pageName = uni.getStorageSync('pageName')
				var templetName = uni.getStorageSync('templetName')
				var div = that.div
				let i18nArr = uni.getStorageSync('i18nArr')
				let i18n = uni.getStorageSync('i18n')
				for(var i=0; i<div.length; i++){
					if(div[i].divType == 'commonmod'){
						var commonmod = div[i].style
						var replaceConditions = {}
						var replaceColumns = commonmod.replaceColumns
						if(JSON.stringify(replaceColumns) != '[]'){
							for(var m=0;m<replaceColumns.length;m++){
								replaceConditions[replaceColumns[m].toReplace] = replaceColumns[m].value
							}
						}
						var injson = that.$requestDataPre(that.preoptions, div[i].divArea,commonmod.dataObject,replaceConditions,{},that.pageConditions)
						
						uni.request({
							url: getApp().globalData.app_address + '?method=saas_PageDivData&parse=json',
							data: injson,
							method: 'POST',
							header: { 'content-type': 'application/x-www-form-urlencoded' },
							success: function(res) {
								var result = res.data;
								console.log(result)
								if(result.rtn == 1 && JSON.stringify(result.data.div.value) != '[]'){
									var values = result.data.div.value
									for(var j=0;j<values.length;j++){
										values[j].piciconurl = getApp().globalData.pic_address + values[j].piciconurl
										if(i18n === 'en' && i18nArr!=undefined){
											values[j].menuname = that.$translg(values[j].menuname,i18nArr)
										}
									}
									var id = ''
									var pid = ''
									values = that.$structureTreeData(values, id = "menuid", pid ="parentmenuid")
									commonmod['value']  = values
									
								}
								
								
								that.commonmod = commonmod
								console.log(that.commonmod)
								that.$forceUpdate()
							},
						})
					}
				}
			},
		
			updatetopsum(){
				var that = this
				var nginxurl = uni.getStorageSync('nginxurl')
				var webname = uni.getStorageSync('webname')
				var sessionid = uni.getStorageSync('sessionid')
				var dbid = uni.getStorageSync('dbid')
				var loginid = uni.getStorageSync('loginid')
				uni.showLoading({title: '加载中'})
				var injsontopsum = '{"sessionid":"' + sessionid + '","dbid":"' + dbid + '"}'
				uni.request({
					url: nginxurl + '/' + webname + '/assaas',
					data: {method: util.encode('sj_index_topsumnumbers'),parse: util.encode('json'),injson: util.encode(injsontopsum)},
					method: 'GET',
					header: {'content-type': 'application/json'},
					success: function(res) {
						uni.hideLoading()
						var result5 =  JSON.parse(util.decode(res.data))
						that.topsumnumbers = result5.DATA.data
					}
				})
			},
			
			btnclick(type,btnvalue){
				var that = this
				var code = ''
				if(type == 'phone'){
					uni.makePhoneCall({
					    phoneNumber: btnvalue
					});
				}
				if(type=='scan'){
					uni.scanCode({
					    success: function (res) {
					        console.log('条码类型：' + res.scanType);
					        console.log('条码内容：' + res.result);
							var scancode = res.result
							var nginxurl = uni.getStorageSync('nginxurl')
							var webname = uni.getStorageSync('webname')
							var sessionid = uni.getStorageSync('sessionid')
							var dbid = uni.getStorageSync('dbid')
							var injson = '{"sessionid":"' + sessionid + '","dbid":"' + dbid + '","scancode":"'+scancode+'","isvalet":"2"}'
							uni.request({
								url: nginxurl + '/' + webname + '/assaas',
								data: {method: util.encode('up_nbmtdh_spu_count'),parse: util.encode('json'),injson: util.encode(injson)},
								method: 'GET',
								header: {'content-type': 'application/json'},
								success: function(res) {
									var result = JSON.parse(util.decode(res.data));
									console.log(result)
									if(result.DATA.errmsg!=''){
										uni.showModal({
										    title: '提示',
										    content: result.DATA.errmsg,
											showCancel:false
										});
									}else{
										
										var resultdata = result.DATA.data[0]
										if(resultdata.skucount>1){
											uni.navigateTo({url:"../goodlist/goodlist?spu="+resultdata.spu+'&code='+code+'&cartcount='+that.cartcount})
										}else{
											uni.navigateTo({url:'../gooddetail/gooddetail?scancode='+scancode+'&code='+code+'&cartcount='+that.cartcount})
										}
									}
								}
							})
					    }
					});
				}
				if(type=='input'){
					uni.navigateTo({url:'../search/search?code='+code})
				}
			},
			
			navigateto(item){
				var that = this
				var code = item.window
				console.log(item)
				if(code=="SPU"){//库存查询
					uni.navigateTo({url:'/pages/classify1/classify?code='+code})
				}else if(code=='SPSQ'){
					uni.navigateTo({url:'/pages/goodsadd/goodsadd?code='+code+'&opt=add'})
				}else if(code=='SPSH'){
					uni.navigateTo({url:'/pages/goodsedit/goodsedit?code='+code})
				}else if(code=='appsj_list'){
					var modcode = item.modcode
					var title = item.title
					var pagename = ''
					console.log(item)
					var isdataall = item.isdataall
					uni.navigateTo({url:'/pages/infolist/infolist?modcode='+modcode+'&title='+title+'&window='+code+'&pagename='+pagename+'&isdataall='+isdataall})
				}else if(code=='appsj_dkxd'){
					 uni.navigateTo({url: '/pages/customer/customer'})
				}
			},
		}
	}
</script>



<style>
	.split{width: 100vw;height: 10px;background-color: #CCCCCC;}
	.swiper_container { background-color: #F0F0F0; color: #e85a71;  height: 50rpx; margin:  5px; width:calc(100vw - 30px); }
	.swiper_item { font-size: 18px; display: flex; align-items: center; text-align: center; vertical-align: middle;  overflow: hidden;  text-overflow: ellipsis;  white-space: nowrap; }
	.swiper_txt{ display: flex; padding-left: 3px; padding-bottom: 2px; line-height: 50rpx; }
	.error-view{display: flex;color: #aaa;justify-content: center;flex-direction: column;align-items: center;}
	.cmd{display: flex;align-items: center;width: 100%;flex-wrap: wrap;}
	.cmdi{display: flex;justify-content: center;font-size: 12px;color: #333; align-items: center;flex-direction: column;padding: 5px 0;}
</style>
